package com.hifar.test.unitclassify.mapper;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hifar.test.unitclassify.pojo.HfPrjUnitClassify;
import com.hifar.test.unitclassify.pojo.HfPrjUnitClassifyAndUnitVo;
import com.hifar.test.unitclassify.pojo.VO.HfPrjUnitClassifyVO;
import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 项目-检测项目-分类 mapper接口
 * </p>
 *
 * @author wangkepeng
 * @since 2024-12-03 18:06:03
 */
@Mapper
public interface HfPrjUnitClassifyMapper extends BaseMapper<HfPrjUnitClassify> {

    Page<Map<String, Object>> selectTestMethod(Page<Map<String, Object>> rowPage, @Param("sqlString") String sqlString);

    Page<Map<String, Object>> selectTestQueryWrapper(Page<Map<String, Object>> rowPage, @Param(Constants.WRAPPER) QueryWrapper wrapper);

    Page<HfPrjUnitClassify> selectTestQueryWrapperObj(Page<HfPrjUnitClassify> rowPage, @Param(Constants.WRAPPER) QueryWrapper wrapper);

    @Select(" SELECT * from (select b.id_name,b.user_code,"
            + "           a.*,a.CLASSIFY_NAME as classify_name_a  "
            + "        FROM "
            + "            HF_PRJ_UNIT_CLASSIFY a ,base_org_user b ) x     ${ew.customSqlSegment}  ")
    Page<HfPrjUnitClassify> selectTestQueryWrapperObj4(Page<HfPrjUnitClassify> rowPage, @Param(Constants.WRAPPER) QueryWrapper wrapper);

    @Results({
            @Result(property = "id_name_b", column = "id_name")

    })
    @Select(" SELECT * from (select b.id_name,b.user_code,"
            + "           a.*,a.CLASSIFY_NAME as classify_name_a  "
            + "        FROM "
            + "            HF_PRJ_UNIT_CLASSIFY a ,base_org_user b ) x     ${ew.customSqlSegment}  ")
    Page<HfPrjUnitClassifyVO> selectTestQueryWrapperObj5(Page<HfPrjUnitClassifyVO> rowPage, @Param(Constants.WRAPPER) QueryWrapper wrapper);


    @Select(" SELECT * from (select UNIT_NAME as NAME, CLASSIFY_ID AS PID,  2 as DATA_TYPE, ID, TENANT_ID, CLASSIFY_ID,  CLASSIFY_NAME, UNIT_CODE, UNIT_NAME, DEPT_ID, SECRET_LEVEL, REMARKS, STATUS, ROW_SORT, CREATE_USER_ID, CREATE_USER_NAME, CREATE_TIME, UPDATE_USER_ID, UPDATE_USER_NAME, UPDATE_TIME, DEL_FLAG from HF_PRJ_UNIT_BASE where del_flag=0  "
            + "union all  "
            + "select CLASSIFY_NAME as name,  PID,1 as DATA_TYPE, ID, TENANT_ID, id as CLASSIFY_ID, CLASSIFY_NAME,'' as UNIT_CODE,'' as UNIT_NAME, DEPT_ID, SECRET_LEVEL, REMARKS, STATUS, ROW_SORT, CREATE_USER_ID, CREATE_USER_NAME, CREATE_TIME, UPDATE_USER_ID, UPDATE_USER_NAME, UPDATE_TIME, DEL_FLAG from HF_PRJ_UNIT_CLASSIFY  where del_flag=0   "
            + " ) x     ${ew.customSqlSegment}  ")
    List<HfPrjUnitClassifyAndUnitVo> listHfPrjUnitClassifyAndUnitVo(@Param(Constants.WRAPPER) QueryWrapper wrapper);

}